//
//  EDSUtility.h
//  DrivieSchoolStudents
//
//  Created by TangBin on 2019/5/22.
//  Copyright © 2019 班文政. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <YYWebImageManager.h>
#import <CoreLocation/CoreLocation.h>


NS_ASSUME_NONNULL_BEGIN

@interface EDSUtility : NSObject


//[UserDefault objectForKey:KuserDefaultsLocation];

+ (id)objectForKey:(NSString *)key;

+ (void)setObject:(id)value forKey:(NSString *)key;

+ (void)removeObjectForKey:(NSString *)key;

/**
 根据秒得到格式化的：00:00:00

 @param totalTime totalTime description
 @return return value description
 */
+ (NSString *)getMMSSFromSS:(NSInteger)totalTime;

/**
 视频缓存路径

 @return return value description
 */
+ (NSString *)getVideoCachePath;

/**
 得到文件的大小

 @param path path description
 @return return value description
 */
+ (CGFloat)getFileSize:(NSString *)path;

/**
 得到视频的长度

 @param URL URL description
 @return return value description
 */
+ (CGFloat)getVideoLength:(NSURL *)URL;

/**
 删除文件

 @param url url description
 */
+ (void)removeWithLocalFile:(NSURL *)url;

/**
 获取视频的第一帧图片

 @param url url description
 @param size size description
 @return return value description
 */
+ (UIImage *)firstFrameWithVideoURL:(NSURL *)url size:(CGSize)size;


/**
 进入登录页面

 @param presentVC presentVC description
 @param completion completion description
 */
+ (void)presentLoginVC:(UIViewController *)presentVC animated:(BOOL)animated completion:(void(^ __nullable)(void))completion;

/**
 拼接http地址

 @param url url description
 @return return value description
 */
+ (NSString *)joinHttpUrl:(NSString *)url;

/// 拼接图片http地址
/// @param url url description
+ (NSString *)joinImageHttpUrl:(NSString *)url;

/**
 删除根地址

 @param url 带有根地址的地址
 @return return value description
 */
+ (NSString *)removeBaseUrl:(NSString *)url;

/**
 改变图片透明度 渐变

 @return return value description
 */
+ (CAGradientLayer *)changeImageAlpha:(CGRect)bounds;

/**
 计算两点之间的距离

 @param lon1 经度1
 @param lat1 纬度1
 @param lon2 经度2
 @param lat2 纬度2
 @return 返回距离
 */
+ (double)LantitudeLongitudeDist:(double)lon1 other_Lat:(double)lat1 self_Lon:(double)lon2 self_Lat:(double)lat2;


/**
 用户当前的经度

 @return 经度
 */
+ (double)userCurrentLongitude;

/**
 用户当前的纬度

 @return 纬度
 */
+ (double)userCurrentLatitude;

+ (NSMutableAttributedString *)attributeTitle:(NSString *)title titleColor:(UIColor *)titleColor titleFont:(UIFont *)titleFont value:(NSString *)value valueColor:(UIColor *)valueColor valueFont:(UIFont *)valueFont;

/**
 * @brief 把缓冲数据存储到本地
 * @param arckey 键
 * @param filename 文件名
 * @param data 存储到制定文件中的对象
 */
+ (void)writeCacheDataLocalKey:(nullable NSString *)arckey saveFilename:(NSString *)filename saveid:(nullable id)data;

/**
 * @brief 从本地读取缓存里面的数据
 * @param arckey 键
 * @param filename 文件名
 */
+ (id _Nullable)readCacheDataLocalKey:(nullable NSString *)arckey saveFilename:(nullable NSString *)filename;

/**
 * @brief 删除缓存里面的数据
 * @param arckey 键
 * @param filename 文件名
 */
+ (void)removeCacheDataLocalKey:(nullable NSString *)arckey fileName:(nullable NSString *)filename;


//保存Cookie
+ (void)saveCookies;

/**
 加载Cookie 一般都是app刚刚启动的时候
 */
+ (void)loadCookies;





/**
 将字符串转成数字
 
 @param strNum @"22"
 @return return value description
 */
+ (NSInteger)stringChangeDigital:(NSString *)strNum;

/**
 拨打电话
 
 @param mobile 电话
 */
+ (void)actioinCall:(NSString *)mobile;

/**
 加入缓存

 @param object 缓存对象
 @param key key
 */
+ (void)addCacheObject:(id)object forKey:(NSString *)key;

/**
 得到缓存数据

 @param key key description
 @return return value description
 */
+ (id)getCacheObject:(NSString *)key;

/**
 删除指定的缓存
 
 @param key key
 */
+ (void)removeCacheKey:(NSString *)key;

+ (YYWebImageManager *)avatarImageManager;

/**
 匹配 @用户名

 @return return value description
 */
+ (NSRegularExpression *)regexAt;


/**
 表情匹配

 @return return value description
 */
+ (NSRegularExpression *)regexEmoticon;

/**
 表情

 @return return value description
 */
+ (NSDictionary *)emoticonDic;

+ (UIImage * _Nullable)imageWithPath:(NSString *)path;

/**
 判断用户是否已经登录

 为了兼容学员端
 
 @return YES表示登录；NO表示没有登录
 */
+ (BOOL)isUserLogin;

/**
 把国测局的坐标转成百度的坐标
 
 @param latitude 国测局的经度
 @param longitude 经度
 @return 返回百度的坐标
 */
+ (CLLocationCoordinate2D)changePoints:(double)latitude longitude:(double)longitude;


/**
 百度地图金纬度转高德地图经纬度
 
 @param coordinate 百度经纬度
 @return 返回高德地图经纬度
 */
+ (CLLocationCoordinate2D)getGaoDeCoordinateByBaiDuCoordinate:(CLLocationCoordinate2D)coordinate;

/**
 将高得地图经纬度转百度地图经纬度
 
 @param coordinate 高度经纬度
 @return 返回百度经纬度
 */
+ (CLLocationCoordinate2D)getBaiDuCoordinateByGaoDeCoordinate:(CLLocationCoordinate2D)coordinate;


+ (UIImage *)imageWithRotation:(UIImage *)image;


/// 业务提醒 当天 就返回时间(10:32)；昨天就返回昨天，其它返回日期
/// @param date 日期时间
+ (NSString *)formatBusinessReminderDate:(NSString *)date;

/// 判断字符串中是否含有中文
/// @param string string description
+ (BOOL)isChineseChar:(NSString *)string;

+ (NSString *)getTmpFileUrl:(NSString *)url;


/// 获取字符串首字母(传入汉字字符串, 返回大写拼音首字母)
/// @param aString aString description
+ (NSString *)getFirstLetterFromString:(NSString *)aString;

/// 在不在26个字母中
/// @param str str description
+ (BOOL)matchLetter:(NSString *)str;

/// 显示错误提示视图
/// @param msg 信息
/// @param defMsg 默认信息
+ (void)showErrorTipView:(NSString *)msg defMsg:(NSString *)defMsg;

/// 生成二维码
/// @param string string description
/// @param size size description
+ (UIImage *)generateQRCodeWithString:(NSString *)string Size:(CGFloat)size;


/// 查看字体库
+ (void)findFontName;


/// 创建navBar 右边的按钮
/// @param title title description
/// @param titleColor titleColor description
/// @param action action description
+ (UIButton *)createNavBtnRight:(NSString *)title titleColor:(UIColor * _Nullable)titleColor action:(SEL)action targetId:(id)targetId;

/// 判断中英混合的的字符串长度
/// @param strtemp strtemp description
+ (int)convertToInt:(NSString *)strtemp;


/// //12小时之内是按小时，超过12小时按天，超过3天按日期
/// @param time time description
+ (NSString *)dateTimePraise:(NSString *)time;

/// 判断手机号码格式是否正确
/// @param mobile mobile description
+ (BOOL)valiMobile:(NSString *)mobile;

+ (NSString *)httpWithUrlDecode:(NSString *)url;

///// 写文件到本地
///// @param error error description
//+ (void)redirectLogToDocumentFolder:(NSString *)error;

/// 分享
/// @param model model description
+ (void)showShared:(nullable id)model;

/**
 发起分享

 @param platformType 分享平台类型
 @param model model description
 */
//+ (void)sendShare:(UMSocialPlatformType)platformType model:(nullable id)model;


/// 格式化
/// @param dateTime dateTime description
+ (NSString *)formatBalanceTime:(NSString *)dateTime;

/// 把url地址后面的文件名转码
/// @param url url description
+ (NSString *)parseUrl:(NSString *)url;

/// 解码
/// @param url url description
+ (NSString *)parseWithDecode:(NSString *)url;
// [url stringByURLDecode]

/// 生成随机数
/// @param num 位数
+ (NSString *)generateTradeNO:(NSInteger)num;

/// 通过CAShapeLayer方式绘制虚线
/// @param lineView 需要绘制成虚线的view
/// @param lineLength 虚线的宽度
/// @param lineSpacing 虚线的间距
/// @param lineColor 虚线的颜色
/// @param isHorizonal 虚线的方向 YES 水平方向；NO为垂直方向
+ (void)drawLineOfDashByCAShapeLayer:(UIView *)lineView lineLength:(int)lineLength lineSpacing:(int)lineSpacing lineColor:(UIColor *)lineColor lineDirection:(BOOL)isHorizonal;

/// 将秒转成 00:00
/// @param second second description
+ (NSString *)minuteSecondFormat:(NSInteger)second;

/// 判断输入的是否是车牌号(普通车牌号 和 新能源车牌号)
/// @param carNumber carNumber description
+ (BOOL)isValidCarNumber:(NSString *)carNumber;

/// 判断是否是普通车牌号
/// @param carNumber carNumber description
+ (BOOL)isValidOrdinaryPlateNumber:(NSString *)carNumber;

/// 判断是否是新能源车 车牌号
/// @param carNumber carNumber description
+ (BOOL)isValidNewEnergyPlateNumber:(NSString *)carNumber;

/// 判断是否是vin码
/// @param vin vin description
+ (BOOL)isValidVIN:(NSString *)vin;

/// 根据id得到名称
/// @param serFlow serFlow description
+ (NSString *)getServFlowName:(NSInteger)serFlow;

/// 获取视频的第一帧的图片
/// @param videoURL 视频地址
/// @param iconImageView iconImageView description
+ (void)videoImageWithVideoURL:(NSURL *)videoURL imgView:(UIImageView *)iconImageView;


+ (UIViewController *)cl_findBestViewController:(UIViewController *)vc;

+ (UIViewController *)cl_currentViewController;

/// 判断是不是 字母和数字的组合
/// - Parameter string: string description
+ (BOOL)isAlphaNumeric:(NSString *)password;

@end

NS_ASSUME_NONNULL_END























